#!/usr/bin/env python
# coding: utf8

import zbar
import Image

# create a reader
scanner = zbar.ImageScanner()


# configure the reader
scanner.parse_config('enable')

# obtain image data
pil = Image.open('./55.jpg').convert('L')
width, height = pil.size
#pil.show()
raw = pil.tostring()

# wrap image data
image = zbar.Image(width, height, 'Y800', raw)

# scan the image for barcodes
scanner.scan(image)

# extract results
for symbol in image:
    # do something useful with results
    print symbol.type, '图片内容为:\n%s' % symbol.data

# clean up
del(image)
